package HierarchyPackage;

import ClassifiedDataSetPackage.ClassifiedDataSet;
import DataSetPackage.View;

import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.Set;

/**
 * Common interface for the Hierarchy-classes.
 * @author Martin Haulrich
 */
public interface Hierarchy {

    /**
     * Returns a <code>classifiedDataSet</code> containings classifications for the dataset.
     * @param dids ID of the datapoints in to classify.
     * @param dv View on the dataset containing the data points that should be classified.
     * @param topClass Class to classify with respect to.
     * @param maxDepth Maximum depth of classifications.
     * If an error arises during the classification this Exception is thrown.
     * This error could for instance be problem with reading the data using the view <code>dv</code>.
     * @return A <code>classifiedDataset</code> containing classifications for the dataset.
     */
    public ClassifiedDataSet getClassifications(Collection<Integer> dids, View dv, HClass topClass,
            int maxDepth, int minCount, int cutFraction, boolean saveData);

    /**
     * Get intersection of classes.
     * Finds classes that represents an intersection of the input classes. Hopefully this set is smaller than the input set.
     * @param classes Classes to find intersection of.
     * @return Set of classes representing the intersection of the input classes.
     * Exception thrown when there are problems accesing the hierarchy.
     */
    public Set<HClass> getIntersection(HClass[] classes);

    public Set<HClass> getIntersection(HClass c1, HClass c2);


    //  public HClass getIntersection(HClass c1, HClass c2)  ;
    /**
     * Returns TOP-class for hierarchy.
     * @return TOP-class.
     * Exception thrown when there are problems accesing the hierarchy.
     */
    public HClass getTop();

    /**
     * Returns a string-representation of a given class.
     * The class must belong to this hierarchy.
     * @param c Class to get string-representation for.
     * @return String representation of class.
     * Exception thrown when there are problems accesing the hierarchy.
     */
    public String getName(HClass c);

    /**
     * Check whether <code>c1</code> is superclass to <code>c2</code>.
     * Returns false if classes does not belong to the hierarchy.
     * @param c1 Possible superclass.
     * @param c2 Possible subclass.
     * @return True if <code>c1</code> if superclass of <code>c2</code>.
     * Exception thrown when there are problems accesing the hierarchy.
     */
    public boolean superclassOf(HClass c1, HClass c2);

    public boolean isClassifiedBy(Integer did, View dv, HClass classification);

    public Map<HClass, Integer> saveEst(String filename, Set<HClass> classes) throws IOException;

    public Map<Integer, HClass> loadEst(String filename, Set<Integer> classIDs) throws IOException;

    public String getType();

    public HClass newClass(Integer did, View v);
}
